package com.zy.openchat.core.model.message;

import android.os.Parcel;
import android.os.Parcelable;

import com.google.gson.annotations.SerializedName;

public class ChatType implements Parcelable {
    @SerializedName("@type")
    public String type;
    //单聊时有效
    public long user_id;
    public long secret_chat_id;
    //讨论组时有效
    public long basic_group_id;
    //超级讨论组时有效
    public long supergroup_id;
    public boolean is_channel;


    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.type);
        dest.writeLong(this.user_id);
        dest.writeLong(this.secret_chat_id);
        dest.writeLong(this.basic_group_id);
        dest.writeLong(this.supergroup_id);
        dest.writeByte(this.is_channel ? (byte) 1 : (byte) 0);
    }

    public void readFromParcel(Parcel source) {
        this.type = source.readString();
        this.user_id = source.readLong();
        this.secret_chat_id = source.readLong();
        this.basic_group_id = source.readLong();
        this.supergroup_id = source.readLong();
        this.is_channel = source.readByte() != 0;
    }

    public ChatType() {
    }

    protected ChatType(Parcel in) {
        this.type = in.readString();
        this.user_id = in.readLong();
        this.secret_chat_id = in.readLong();
        this.basic_group_id = in.readLong();
        this.supergroup_id = in.readLong();
        this.is_channel = in.readByte() != 0;
    }

    public static final Creator<ChatType> CREATOR = new Creator<ChatType>() {
        @Override
        public ChatType createFromParcel(Parcel source) {
            return new ChatType(source);
        }

        @Override
        public ChatType[] newArray(int size) {
            return new ChatType[size];
        }
    };
}
